package za.co.felixsol.sf.gcode.instructions.tests;

import java.io.FileOutputStream;
import java.io.OutputStream;

import za.co.felixsol.sf.gcode.Program;
import za.co.felixsol.sf.gcode.instructions.F;
import za.co.felixsol.sf.gcode.instructions.G0;
import za.co.felixsol.sf.gcode.instructions.G1;
import za.co.felixsol.sf.gcode.instructions.G90;
import za.co.felixsol.sf.gcode.instructions.M2;
import za.co.felixsol.sf.gcode.instructions.io.BasicInstructionWriter;

public class InstructionWriterTest {

	public static void main(String[] args) {

		try {

			Program program = new Program();			
			program.getInstructions().add(new G90());
			program.getInstructions().add(new F(100d));
			program.getInstructions().add(new G0(0d, 0d, 0d));
			program.getInstructions().add(new G1(0d, 1d, 0d));
			program.getInstructions().add(new G1(0d, 0d, 1d));
			program.getInstructions().add(new G1(0d, 0d, 0d));
			program.getInstructions().add(new M2());
			
//			OutputStream os = new FileOutputStream("c:/temp/gcode1.ng");
//			try {
				// BasicInstructionWriter writer = new BasicInstructionWriter(os);
				BasicInstructionWriter writer = new BasicInstructionWriter(System.out);
				writer.write(program);
//			} finally {
//				os.close();
//			}
			
			
		} catch (Exception ex) {
			ex.printStackTrace();
		}

		System.out.println("Done!");
	}

}
